package kr.pe.johnkim.chattingday.mobile.rest.dao;

import kr.pe.johnkim.chattingday.mobile.domain.ChattingDayPrivateJoiner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * Chatting Day 쪽지 사용자 관련 Dao 메소드들을 구현한 클래스 이다.
 * 
 * @author : johnkim <cale9797@gmail.com / Bettersoft Inc,.>
 * @Date : 12. 6. 12
 */
public class ChattingDayPrivateJoinerDaoImpl extends SqlMapClientDaoSupport implements ChattingDayPrivateJoinerDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(ChattingDayPrivateJoinerDaoImpl.class);
    
    /**
     * 쪽지 사용자를 등록 한다.
     *
     * @return
     */
    @Override
    public boolean registerPrivateJoiner(ChattingDayPrivateJoiner chattingDayPrivateJoiner) {
        logger.info("registerPrivateJoiner");

        boolean result;

        try {
            getSqlMapClientTemplate().insert("CHATTINGDAY_PRIVATE_JOINERS.registerPrivateJoiner", chattingDayPrivateJoiner);
            result = true;
        } catch (Exception e) {
            result = false;
        }

        return result;
    }

    /**
     * 쪽지 사용자를 비활성화 한다.
     *
     * @param chattingDayPrivateJoiner
     * @return
     */
    @Override
    public boolean updateDeactivatePrivateJoiner(ChattingDayPrivateJoiner chattingDayPrivateJoiner) {
        logger.info("updateDeactivatePrivateJoiner");

        boolean result;

        try {
            getSqlMapClientTemplate().update("CHATTINGDAY_PRIVATE_JOINERS.updateDeactivatePrivateJoiner", chattingDayPrivateJoiner);
            result = true;
        } catch (Exception e) {
            result = false;
        }

        return result;
    }

    /**
     * 쪽지함의 모든 사용자를 비활성화 한다.
     *
     * @param chattingDayPrivateJoiner
     * @return
     */
    @Override
    public boolean updateDeactivatePrivateAllJoiner(ChattingDayPrivateJoiner chattingDayPrivateJoiner) {
        logger.info("updateDeactivatePrivateAllJoiner");

        boolean result;

        try {
            getSqlMapClientTemplate().update("CHATTINGDAY_PRIVATE_JOINERS.updateDeactivatePrivateAllJoiner", chattingDayPrivateJoiner);
            result = true;
        } catch (Exception e) {
            result = false;
        }

        return result;
    }
}
